/*
  @author dmj1161859184@126.com 2018-08-05 13:46
  @version 1.0
  @since 1.0
*/

//Reference: https://juejin.im/post/59658504f265da6c415f3324
let shallowCopy = function(obj) {
    // 只拷贝对象
    //if (typeof obj !== 'object') return; 不应该是下面这个样子吗
    if (typeof obj !== 'object') return obj;
    // 根据obj的类型判断是新建一个数组还是对象
    var newObj = obj instanceof Array ? [] : {};
    // 遍历obj，并且判断是obj的属性才拷贝
    for (var key in obj) {
        if (obj.hasOwnProperty(key)) {
            newObj[key] = obj[key];
        }
    }
    return newObj;
};